-- PaladinExperience
-- Created by huanghr Mar/4/2016
-- 圣骑士的心得

-- 初始化
function initPaladinExperience(self)
    self.item:removeAllChildren();

    local class = self.gridData.class;
    local buildingInfo = BuildingBonusM.queryBuildingView(class);

    if not buildingInfo then
        error("获取不到建筑查看配置，元素类型：" .. class);
        return;
    end

    local function onClicked(sender, eventType)
        if eventType == ccui.TouchEventType.began then
            if self.gridData.state == GRID_STATE_DISABLE then
                -- 已经失效，不处理
                return;
            end

                 -- 更新建筑访问
            AudioM.playFx("ui_open1");
            self:updateBuildingVisit();

            local function okFunc()
                local pos = self.gridData:getPos();
                local ret = DungeonActionM.go("do_paladin_experience_bonus", pos);
                if type(ret) == "string" then
                    alert(getLocStr(ret));
                end
            end
            self:openBuildingView(okFunc);
        end
    end

    local iconPath = getLevelItemIconPath(buildingInfo["icon"]);
    self.icon = ccui.ImageView:create(iconPath);
    self.icon:setTouchEnabled(true);
    self.icon:addTouchEventListener(onClicked);
    self.item:addChild(self.icon);

    -- 发光
    if self.gridData.need_shining == 1 then
        shiningEffect(self.icon, 70, 100);
    end
end
